package com.atguigu.e_ticket;

public class Ticket implements Runnable{
    int count = 50;

    Object object = new Object();
    @Override
    public void run() {
        while (true){
            synchronized (object){
                if (count>0){
                    System.out.println(Thread.currentThread().getName()+"买到了第"+count+"张票,剩余"+(--count)+"张票");
                }
            }
        }
    }
}
